<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../css/bootstrap.min.css">
	<script src="../js/jquery-1.11.1.min.js"></script> 
     <script src="../js/bootstrap.min.js"></script>
	<link rel="stylesheet" href="../css/wpl_style.css">
<?php include 'dbInclude.php';?>
</head>
<body class="gridBody">
<div id="btndiv">
<label style="width:90%;text-align:center">Order History</label>
<img id="refresh" src="../img/refresh_new.png"></img>
</div>
<div id="fillref" class="CSSTableGenerator">
<table>
<tr class="tbhd"><td>Order No.</td><td>Company</td><td>Buy/Sell</td><td>LTP</td><td>Quantity</td><td>Status</td></tr>
<?php

ob_start();
    session_start();
	
    if(isset($_SESSION['sess_client_id']) && !empty($_SESSION['sess_client_id'])) {
		$clid = $_SESSION['sess_client_id'];
	$rows=$dbh->query("select * from orders O, instrument_master I where O.INSTR_ID = I.INSTR_ID and O.CLIENT_ID = ".$clid." ORDER BY O.ORDER_ID; ");
foreach ($rows as $row) {
echo "<tr>";
$ono = $row['ORDER_ID'];
$instname = $row['INSTR_NAME'];
$b_s = $row['BUY_SELL'];
$bal = $row['LTP'];
$qnty = $row['QUANTITY'];
$status = $row['STATUS'];
$b_s1="";
if($b_s==1)
{
	$b_s1 = "Buy";
}
else
{
	$b_s1 = "Sell";
}
$sta = "";
if($status=='P')
{
	$sta = "Pending";
}
else
{
	$sta = "Executed";
}
echo "<td>".$ono."</td>";
echo "<td>".$instname."</td>";
echo "<td>".$b_s1."</td>";
echo "<td class='price'>".$bal."</td>";
echo "<td>".$qnty."</td>";
echo "<td>".$sta."</td>";
echo "</tr>";
}
}
?>
</table>
</div>
</body>
<script>
$("#refresh").click(function(){
$.ajax({
  type: "POST",
  url: "ajax_orderhistory.php",
  
})
  .done(function( data ) {
    $("#fillref").html(data);
	//alert(data);
	});

});
</script>
</html>